package com.visual.core.domain;

import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.visual.util.annotation.DEField;
import com.visual.util.domain.EntityMP;
import com.visual.util.enums.DEPredefinedFieldType;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.io.Serializable;

/**
 * 实体[可视化分类表]
 */
@Getter
@Setter
@NoArgsConstructor
@JsonIgnoreProperties(value = "handler")
@TableName(value = "blade_visual_category", resultMap = "BladeVisualCategoryResultMap")
@ApiModel("可视化分类表")
public class BladeVisualCategory extends EntityMP implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 主键
     */
    @DEField(isKeyField = true)
    @TableId(value = "id", type = IdType.ASSIGN_ID)
    @JSONField(name = "id")
    @JsonProperty("id")
    @ApiModelProperty("主键")
    private Long id;
    /**
     * 分类键值
     */
    @DEField(name = "category_key")
    @TableField(value = "category_key")
    @JSONField(name = "categorykey")
    @JsonProperty("categorykey")
    @ApiModelProperty("分类键值")
    private String categorykey;
    /**
     * 分类名称
     */
    @DEField(name = "category_value")
    @TableField(value = "category_value")
    @JSONField(name = "categoryvalue")
    @JsonProperty("categoryvalue")
    @ApiModelProperty("分类名称")
    private String categoryvalue;
    /**
     * 是否已删除
     */
    @DEField(name = "is_deleted", preType = DEPredefinedFieldType.LOGICVALID, logicval = "0", logicdelval = "1")
    @TableLogic(value = "0", delval = "1")
    @TableField(value = "is_deleted")
    @JSONField(name = "isdeleted")
    @JsonProperty("isdeleted")
    @ApiModelProperty("是否已删除")
    private Integer isdeleted;



    /**
     * 设置 [分类键值]
     */
    public void setCategorykey(String categorykey) {
        this.categorykey = categorykey;
        this.modify("category_key", categorykey);
    }

    /**
     * 设置 [分类名称]
     */
    public void setCategoryvalue(String categoryvalue) {
        this.categoryvalue = categoryvalue;
        this.modify("category_value", categoryvalue);
    }


    @Override
    public Serializable getDefaultKey(boolean gen) {
        return IdWorker.getId();
    }
    /**
     * 复制当前对象数据到目标对象(粘贴重置)
     * @param targetEntity 目标数据对象
     * @param bIncEmpty  是否包括空值
     * @param <T>
     * @return
     */
    @Override
    public <T> T copyTo(T targetEntity, boolean bIncEmpty) {
        this.reset("id");
        return super.copyTo(targetEntity, bIncEmpty);
    }
}


